# models.py
# 使用ORM在models.py中对数据库表的model进行设计
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, BLOB, Text
from sqlalchemy.orm import relationship
from database import Base


# 定义 User 类
class User(Base):
    __tablename__ = 'users'  # 定义表名,这里的表明对应着数据库里的
    Email = Column(String(255), primary_key=True, unique=True, index=True, nullable=False)  # 邮箱列，唯一且索引
    Password = Column(String(255), nullable=False)  # 哈希后的密码列
    Role = Column(String(255), nullable=False)
    Telephone = Column(String(255), nullable=False)
    Address = Column(String(255), nullable=False)

    Resume_file = Column(BLOB, nullable=True)
    Resume_text = Column(Text, nullable=True)
    Resume_n = Column(Text, nullable=True)
    Resume_it = Column(Text, nullable=True)
    Education = Column(String(255), nullable=True)
    Name = Column(String(255), nullable=True)

    Email_iv = Column(String(255), nullable=False)
    Telephone_iv = Column(String(255), nullable=False)
    Address_iv = Column(String(255), nullable=False)


# 定义 User 类
class Finder(Base):
    __tablename__ = 'finders'  # 定义表名,这里的表明对应着数据库里的
    Email = Column(String(255), primary_key=True, unique=True, index=True, nullable=False)  # 邮箱列，唯一且索引
    Password = Column(String(255), nullable=False)  # 哈希后的密码列
    Role = Column(String(255), nullable=False)
    Telephone = Column(String(255), nullable=False)
    Address = Column(String(255), nullable=False)

    Require_Title = Column(String(255), nullable=True)
    Title_Salary = Column(String(255), nullable=True)
    Require_Education = Column(String(255), nullable=True)
    Require_Discription = Column(Text, nullable=True)
    Company = Column(String(255), nullable=True)
    Company_Address = Column(String(255), nullable=True)

    Email_iv = Column(String(255), nullable=False)
    Telephone_iv = Column(String(255), nullable=False)
    Address_iv = Column(String(255), nullable=False)